package br.com.andreikeda.utility.gestor.finance.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import br.com.andreikeda.utility.gestor.R;
import br.com.andreikeda.utility.gestor.finance.adapter.CategoriesAdapter;
import br.com.andreikeda.utility.gestor.finance.storage.database.DatabaseHelper;
import br.com.andreikeda.utility.gestor.finance.storage.database.dao.CategoryDAO;
import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * Created by LimaoGames on 22/01/2015.
 * contact me: andreikeda87@gmail.com
 */
public class CategoriesFragment extends Fragment {

    @InjectView(R.id.list_categories)
    protected ListView listCategories;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_categories, container, false);
        ButterKnife.inject(this, view);
        initializeList();
        return view;
    }

    private void initializeList() {
        listCategories.setAdapter(new CategoriesAdapter(getActivity(), CategoryDAO.getInstance().list(DatabaseHelper.getInstance(getActivity()).getWritableDatabase())));
    }
}
